var MongoClient = require('mongodb').MongoClient
var url = "mongodb://127.0.0.1:27017"

MongoClient.connect(url, {useNewUrlParser: true, useUnifiedTopology: true}, function(err, db) {
  if(err) throw err
  var dbo = db.db("laochen")
  var myobj = [
    {_id: 154, name: '笔记本电脑'},
    {_id: 155, name: '耳机'},
    {_id: 156, name: '手机'}
  ];
  dbo.collection("products").insertMany(myobj, function(err, res) {
    if(err) throw err
    console.log("插入的文档数量为：" + res.insertedCount)
    db.close()
  })
})

